{extend name="common/menu_child" /}

{block name="nav"}
<span class="layui-breadcrumb">
	<a>资源回收</a>
	<a href="{:url('index')}">工作人员申请表</a>
	<a><cite>查看详情</cite></a>
</span>
{/block}

{block name="body"}
<div class="layui-form layui-form-pane" style="width:40%;min-width:400px;">
	<div class="layui-form-item">
		<label class="layui-form-label">姓名</label>
		<div class="layui-input-block">
			<input type="text" name="title" value="{$apply.realname}" class="layui-input" disabled />
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">联系电话</label>
		<div class="layui-input-block">
			<input type="text" name="title" value="{$apply.phone}" class="layui-input" disabled />
		</div>
	</div>
	<div class="layui-form-item" pane>
		<label class="layui-form-label">证件照正面</label>
		<div class="layui-input-block">
			<a href="{$domain}{$apply.idcard_frontend}" target="_blank"><img src="{$domain}{$apply.idcard_frontend}" height="100px" /></a>
		</div>
	</div>
	<div class="layui-form-item" pane>
		<label class="layui-form-label">证件照背面</label>
		<div class="layui-input-block">
			<a href="{$domain}{$apply.idcard_backend}" target="_blank"><img src="{$domain}{$apply.idcard_backend}" height="100px" /></a>
		</div>
	</div>
	<div class="layui-form-item" pane>
		<label class="layui-form-label">证件照持证</label>
		<div class="layui-input-block">
			<a href="{$domain}{$apply.idcard_hold}" target="_blank"><img src="{$domain}{$apply.idcard_hold}" height="100px" /></a>
		</div>
	</div>
	<table class="layui-table" lay-skin="line">
		<thead>
			<tr>
				<th colspan="2">地址</th>
			</tr> 
		</thead>
		<tbody>
			{empty name="apply_region"}
			<tr>
				<td>该申请没有包含地址</td>
			</tr>
			{else}
			{foreach name="apply_region" item="vo" key="ko"}
			<tr>
				<td>{$vo}</td>
				{eq name="apply.result" value="0"}
				<td>
					<a title="移除" href="javascript:void(0);" data-id="{$ko}" bind-name="remove_region">
						<i class="layui-icon" style="font-size:18px;">&#x1006;</i>
					</a>
				</td>
				{/eq}
			</tr>
			{/foreach}
			{/empty}
		</tbody>
	</table>
	{eq name="apply.result" value="0"}
	<div>
		<button bind-name="dispose_result" data-result="true" class="layui-btn layui-btn-warm">通过</button>
		<button bind-name="dispose_result" data-result="false" class="layui-btn">拒绝</button>
		
	</div>
	{else/}
	<div class="layui-form-item" pane>
		<label class="layui-form-label">审核结果</label>
		<div class="layui-input-block">
			<input type="radio" name="result" title="通过" disabled {eq name="apply.result" value="1"}checked{/eq} />
			<input type="radio" name="result" title="拒绝" disabled {eq name="apply.result" value="2"}checked{/eq} />
		</div>
	</div>
	{/eq}
</div>
{/block}

{block name="javascript"}
<script type="text/javascript">
	
	layui.use('layer', function(){
		
		$('[bind-name=remove_region]').on('click', function(e){
			layui.layer.confirm('确定要移除该地址吗？', {}, function(){
				let data = {
					action: 'remove_region',
					key: parseInt($(e.currentTarget).attr('data-id'))
				};
				action_post_json('', data, function(response){
					layui.layer.msg(response.message);
					if(0 === response.errno){
						setTimeout(function(){
							window.location.reload();
						}, 1000);
					};
				});
			});
		});
		
		$('[bind-name=dispose_result]').on('click', function(e){
			let result = $(e.currentTarget).attr('data-result');
			let message = '';
			if('true' === result){
				result = true;
				message = '确定要通过吗';
			}else{
				result = false;
				message = '确定要拒绝吗？';
			};
			
			layer.confirm(message, {}, function(){
				let data = {
					action: 'dispose_result',
					result: result
				};
				action_post_json('', data, function(response){
					layer.msg(response.message);
					switch(response.errno){
						case 0 :
							setTimeout('window.location.reload()', 1000);
							break;
					};
				});
			});
		});
		
	});
	
</script>
{/block}